"use strict";
require("test").setup();

var Coroutine = require('coroutine');
var hash = require('hash');

var str_prefix = "ZG";

describe("config", function() {
    before(function() {

    });

    after(function() {
         clearDB();
    });


    it("登录", function() {
        httpPost("GET", "/v1.0/api/user/Sync", {})

        var t = "123"
        var result = httpPost("POST", "/v1.0/api/user/WebLogin", {
            "phone": "18888888888",
            "password": hash.md5(hash.md5("ZHYQ2022").digest().hex() + t).digest().hex(),
            "t": t,
        })
        assert.equal(result.code, "200");
        assert.equal(result.data.id, 2);
        assert.equal(result.data.role, "超级管理员");
        assert.equal(result.data.edited_password, true);
    });

    it("创建患陪(包含患者和陪护)", function() {
        var result = httpPost("POST", "/v1.0/api/accompanyRecord/Create", {
            adminssion_no:"0001",
            adminssion_time: "2022-03-16",
            patient_name:"李四",
            patient_gender:"男",
            patient_phone:"18909786579",
            accompany_name:"三上",
            accompany_gender:"男",
            accompany_phone:"15645674576",
            department:"内科",
            patient_attachments:JSON.stringify([111,2222,333]),
            accompany_attachments:JSON.stringify([111,2222,333])
        })
        assert.equal(result.code, "200");
        assert.equal(result.data.id, 10000);
    });

    it("患陪审批通过", function() {
        var result = httpPost("POST", "/v1.0/api/accompanyRecord/Pass", {
            id:10000,
        })
        assert.equal(result.code, "200");
    });

    it("配置列表", function() {
        var result = httpPost("GET", "/v1.0/api/equipmentDispatch/List", {
        })
        assert.equal(result.code, "200");
    });

    it("配置列表", function() {
        var result = httpPost("GET", "/v1.0/api/equipmentDispatch/List?status=已执行", {
        })
        assert.equal(result.code, "200");
        assert.equal(result.data.list.length, 0);
    });

    xit("配置列表", function() {
        var result = httpPost("GET", "/v1.0/api/equipmentDispatch/List?status=未执行", {
        })
        assert.equal(result.code, "200");
        assert.equal(result.data.list.length, 1);
    });

});

require('test').run();